package com.spring.demo6;

import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MainApp {
	
	/**
	 * Spring内置事件
	 */
	public void testDemo(){
		ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("bean6.xml");
		// Let us raise a start event.
		context.start();
		HelloWorld obj = (HelloWorld) context.getBean("helloWorld");
		obj.getMessage();
		// Let us raise a stop event.
		context.stop();
	}
	/**
	 * Spring自定义事件
	 */
	public void testDemo2(){
		ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("bean6.xml");
		CustomEventPublisher cvp = (CustomEventPublisher) context.getBean("customEventPublisher");
		cvp.publish();
		cvp.publish();
	}
	public static void main(String[] args) {
		new MainApp().testDemo();
		System.out.println("================");
		new MainApp().testDemo2();
	}
}
